package com.bsdsma.visonManagementSystemapp.service;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.bsdsma.visonManagementSystemapp.dto.*;
import com.bsdsma.visonManagementSystemapp.entity.Student;
import com.bsdsma.visonManagementSystemapp.entity.User;
import java.util.Date;
import java.util.List;
import java.util.Map;

/**
 * User business operation interface declaration
 * Handles all user types (Student, Teacher, Admin)
 */
public interface UserService {
    /**
     * Search users with pagination
     * @param dto Search criteria
     * @return Paginated list of users
     */
    PageRetDto<UserDto> search(UserSearchDto dto);

    /**
     * List all users
     */
    List<UserDto> listAll();

    /**
     * List all users with "only mine" flag
     */
    ListAllRetDto<UserDto> listAllWithRet();

    /**
     * Add a new user
     * @param dto User data
     * @param isInit Whether it's an initialization user
     * @return Created user
     */
    UserDto add(UserAddDto dto, boolean isInit);

    /**
     * Update an existing user
     * @param id User ID
     * @param dto Updated user data
     * @return Updated user
     */
    UserDto update(Long id, UserAddDto dto);

    /**
     * Get user by ID
     * @param role User role (学生/教师/超级管理员)
     * @param id User ID
     * @return User data
     */
    UserDto getById(String role, Long id);

    /**
     * Delete a user
     * @param role User role (学生/教师/超级管理员)
     * @param id User ID
     */
    void delete(String role, Long id);

    /**
     * Update user by ID
     * @param id User ID
     */
    int updateById(Long id, UserDto dto);

    /**
     * Count total users
     */
    Long count();

    /**
     * Count users by day
     * @param beginDate Start date
     * @param endDate End date
     */
    List<DataGroupByDateDto> countByDay(Date beginDate, Date endDate);

    /**
     * Get user by account
     * @param account Account name
     * @return User data
     */
    UserDto getByAccount(String account);

    /**
     * Get user by cellphone number
     * @param cellphoneNumber Cellphone number
     * @return User data
     */
    UserDto getByCellphoneNumber(String cellphoneNumber);

    /**
     * Bulk import users
     * @param userList List of users to import
     * @return Import results
     */
    Map<String, Object> bulkImport(List<UserAddDto> userList);

    /**
     * List all students from a specific school
     * @param schoolId School ID
     * @return List of students
     */
    List<Student> listAllStudentsBySchool(Long schoolId);

    /**
     * Search for students based on criteria
     * @param schoolId School ID (can be null)
     * @param grade Grade (can be null)
     * @param name Student name (can be null)
     * @return List of matching students
     */
    List<Student> searchStudents(Long schoolId, String grade, String name);

    /**
     * Get a student by xuehao and status
     * @param xuehao Student number
     * @param status Status (0 for active)
     * @return Student data
     */
    Student getStudentByXuehaoAndStatus(Long xuehao, Integer status);

    /**
     * Get a user by xuehao and status
     * @param user User object containing xuehao and status
     * @return User data
     */
    User getByXuehaoAndStatus(User user);
}
